import Vue from 'vue'
import router from './route'
import axios from 'axios'
import VueAxios from 'vue-axios'
import App from './App.vue'
// import env from './env'
import '../resource/scss/icon.css'
import '../resource/scss/mi-icon.css'
axios.defaults.baseURL = '/api/';//根据前端的跨域方案做调整
axios.defaults.timeout = 8000;  //接口超时
const mock = true;
if (mock) {
    console.log("aa");
    require("./mock/index");
}
//接口错误拦截
axios.interceptors.request.use((response) => {
    let res = response.data;
    if (res) {
        if (res.status === 0) { //成功
            return res.data;
        } else if (res.status === 10) {//未登录
            window.location.href = '/#/login';
        } else {
            alert(res.msg)
        }
    }else{
        // console.log(response);
        return response;
    }
});

Vue.use(VueAxios, axios);
Vue.config.productionTip = false; //生产环境的提示

new Vue({
    render: h => h(App),
    router,
}).$mount('#app');
